package rhinestone.TUI;

import rhinestone.Control.StatisticsController;

/**
 * This is the UI of statistic option.
 *
 * @author Group 2
 * @version 2010.12.24
 */
public class StatisticsUI extends UI {
	private StatisticsController controller;

	public StatisticsUI(StatisticsController controller) {
		this.controller = controller;
	}

	public void startMenu() {
		boolean finished = false;
		while(!finished) {
			printMenu();
			int choice = promptChoiceInput();
			switch(choice) {
				case 1:
					employeeStatisticChoice();
					break;
				case 2:
					customerStatisticChoice();
					break;
				case 3:
					finished = true;
					break;
				default:
					break;
			}
		}
	}

	protected void printMenu() {
		System.out.println("\t(-1-) Print employees statistic");
		System.out.println("\t(-2-) Print customers statistic");
		System.out.println("\t(-3-) Back");
	}

	private void employeeStatisticChoice() {
		String cpr = promptStringInput(CPR_MESSAGE);
		String statistic = controller.getEmployeeStatistic(cpr);
		printStatistic(statistic);
	}

	private void customerStatisticChoice() {
		String cpr = promptStringInput(CPR_MESSAGE);
		String statistic = controller.getCustomerStatistic(cpr);
		printStatistic(statistic);
	}

	private void printStatistic(String statistic) {
		System.out.println(statistic);
	}
}
